package com.example.web;

import com.example.common.ServiceResponse;
import com.example.common.TableServerResponse;
import com.example.pojo.Percentage;
import com.example.service.ILoginService;
import com.example.service.IUserService;
import com.example.vo.SearchUserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pojo.User;

import java.util.Map;

/**
 * @BelongsProject: gxcwhd
 * @BelongsPackage: com.example.web
 * @Author: LJ
 * @CreateTime: 2020-08-13 11:34
 * @Description:
 */
@RestController
@RequestMapping("Manager")
//@CrossOrigin
public class ManagerController {

    @Autowired
    private IUserService userService;

    @Autowired
    private ILoginService loginService;

    //查所有用户
    @RequestMapping("get-userall")
    public TableServerResponse getUserAll(Integer page,Integer limit){
        return userService.getUserAll(page,limit);
    }

    //模糊查询
    @RequestMapping("search-user")
    public TableServerResponse searchUser(SearchUserVO searchUserVO){
        return userService.searchUser(searchUserVO);
    }

    //查制成比例
    @RequestMapping("get-percentage")
    public Map<String,Object> getPercentage(){
        return userService.getPercentage();
    }

    //改制成比例
    @RequestMapping("update-percentage")
    public ServiceResponse updatePercentage(Percentage percentage){
        return userService.updatePercentage(percentage);
    }

    //用户详情
    @RequestMapping("show-user")
    public ServiceResponse showUserInfo(){
        return userService.showUserInfo();
    }

    //登录
    @RequestMapping("login")
    public ServiceResponse login(User user){
        return loginService.login(user);
    }
}
